home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
emulator
/
zxam spectrum
/
zxam_rexx
/
español
/
loadfile.zxam
< prev
next >
Wrap
Text File
|
1995-07-31
|
4KB
|
120 lines
/* Este script carga un snapshot de disco */
/* Usa los conversores internos del emulador (MIRAGE y PC) */
address command
if ~show(ports,ZXAM_REXX) then do
requestchoice 'title "ZXAM Script error..." body "No encuentro el puerto del emulador!!" gadgets "AARGH!"'
exit
end
/* Almacenar el estado inicial del emulador */
running=zxamactrun() /* 1=en marcha */
zxamstop() /* lo paramos */
/* Usamos el requester del programa para cargar el fichero */
oldname=zxamactname() /* nombre actual */
oldformat=zxamactformat() /* formato actual */
nombre=zxamloadrequester('Elige programa Spectrum...')
if nombre='' then exit /* selección cancelada */
bloque=zxampploadfile(nombre) /* cargamos TODO el fichero */
formato=zxamparseloaded(bloque) /* reconoce y carga el fichero */
if formato~='' then do
zxamnameformat(zxamfilepart(nombre),formato)
exit
end
/* Yep! No es formato mirage ni pc. Aqui debemos poner el código para */
/* reconocer los demás formatos */
/* este es simplemente un ejemplo, ya que intenta reconocer el formato MIRAGE */
/* y cargarlo en memoria, colocando los registros adecuadamente */
/* Para cualquier otro formato solo hay que modificar los offsets */
/* para los registros y la memoria */
if length(bloque)=49179 then do /* formato MIRAGE (creo...) */
zxamsetreg(i,c2d(substr(bloque,1,1))) /* registro i */
zxamsetreg(lh2,c2d(substr(bloque,2,2))) /* registro hl' */
zxamsetreg(ed2,c2d(substr(bloque,4,2))) /* registro de' */
zxamsetreg(cb2,c2d(substr(bloque,6,2))) /* registro bc' */
zxamsetreg(f2,c2d(substr(bloque,8,1))) /* registro f' */
zxamsetreg(a2,c2d(substr(bloque,9,1))) /* registro a' */
zxamsetreg(lh,c2d(substr(bloque,10,2))) /* registro hl */
zxamsetreg(ed,c2d(substr(bloque,12,2))) /* registro de */
zxamsetreg(cb,c2d(substr(bloque,14,2))) /* registro bc */
zxamsetreg(yi,c2d(substr(bloque,16,2))) /* registro iy */
zxamsetreg(xi,c2d(substr(bloque,18,2))) /* registro ix */
zxamsetreg(int,bittst(substr(bloque,20,1),2)) /* estado interrupciones */
zxamsetreg(r,c2d(substr(bloque,21,1))) /* registro r */
zxamsetreg(f,c2d(substr(bloque,22,1))) /* registro f */
zxamsetreg(a,c2d(substr(bloque,23,1))) /* registro a */
zxamsetreg(ps,c2d(substr(bloque,24,2))) /* registro sp */
zxamsetreg(pc,zxamfindbyte(0,201)) /* dir de un RET en ROM */
zxamsetreg(im,c2d(substr(bloque,26,1))) /* modo de interrupción */
zxamsetreg(bor,c2d(substr(bloque,27,1))) /* color del borde */
/* colocamos los 48k de RAM */
zxamputmem(16384,substr(bloque,28,49152))
/* ponemos en la ventana el nombre y el formato */
zxamnameformat(zxamfilepart(nombre),'mirage')
zxamnoreload()
exit
end
/* este es otro ejemplo, que carga un fichero en formato PC */
if length(bloque)=49190 then do /* formato PC?? */
if left(bloque,2)~='SP' then break /* mismo tamaño pero sin ID! */
zxamsetreg(cb,c2d(substr(bloque,7,2)))
zxamsetreg(ed,c2d(substr(bloque,9,2)))
zxamsetreg(lh,c2d(substr(bloque,11,2)))
zxamsetreg(f,c2d(substr(bloque,13,1)))
zxamsetreg(a,c2d(substr(bloque,14,1)))
zxamsetreg(xi,c2d(substr(bloque,15,2)))
zxamsetreg(yi,c2d(substr(bloque,17,2)))
zxamsetreg(cb2,c2d(substr(bloque,19,2)))
zxamsetreg(ed2,c2d(substr(bloque,21,2)))
zxamsetreg(lh2,c2d(substr(bloque,23,2)))
zxamsetreg(f2,c2d(substr(bloque,25,1)))
zxamsetreg(a2,c2d(substr(bloque,26,1)))
zxamsetreg(r,c2d(substr(bloque,27,1)))
zxamsetreg(i,c2d(substr(bloque,28,1)))
zxamsetreg(ps,c2d(substr(bloque,29,2)))
zxamsetreg(cp,c2d(substr(bloque,31,2)))
zxamsetreg(bor,c2d(substr(bloque,35,1)))
zxamsetreg(int,bittst(substr(bloque,37,1),0))
zxamsetreg(im,1+bittst(substr(bloque,37,1),1))
/* colocamos los 48k de RAM */
zxamputmem(16384,substr(bloque,39,49152))
/* ponemos en la ventana el nombre y el formato */
zxamnameformat(zxamfilepart(nombre),'PC')
zxamnoreload()
exit
end
/* al final de todo generamos un error, ya que ninguno de los bloques de */
/* reconocimiento ha podido reconocer el formato */
requestchoice 'title "ZXAM Script error..." body "Formato desconocido!!" gadgets "AARGH!"'
if oldname='' then
zxamclearnameformat()
else
zxamnameformat(oldname,oldformat)
/* dejar el emulador como estaba */
if running=1 then zxamrun()
exit